﻿using System;
using System.Data;
using System.Configuration;
using System.IO;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace BCDataCenter
{
    /// <summary>
    /// Summary description for ClassWriteLogErr
    /// </summary>
    public class ClassWriteLogErr
    {
        public ClassWriteLogErr()
        {
            //
            // TODO: Add constructor logic here
            //
        }
        public void ErrorLog(string sErrMsg,string method)
        {
            string sLogFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==> ";
            string sYear = DateTime.Now.Year.ToString();
            string sMonth = DateTime.Now.Month.ToString();
            string sDay = DateTime.Now.Day.ToString();
            string sErrorTime = sYear + sMonth + sDay;


            string sPath = System.Web.HttpContext.Current.Request.Url.AbsolutePath;
            System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
            string sRet = oInfo.FullName;
           


            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(BCDataCenter.Globals.LogUrl() + "/Err") + sErrorTime, true);
            sw.WriteLine(sLogFormat + "\t 1.Page: " + sRet + "\n\t" + "2.Event: " + method + "\n\t" + "3.Detail: " + sErrMsg);
            sw.Flush();
            sw.Close();
        }
        public void LoginLog(string User,string IP)
        {
            string sLogFormat = DateTime.Now.ToShortDateString().ToString() + " " + DateTime.Now.ToLongTimeString().ToString() + " ==> ";
            string sYear = DateTime.Now.Year.ToString();
            string sMonth = DateTime.Now.Month.ToString();
            string sDay = DateTime.Now.Day.ToString();
            string sErrorTime = sYear + sMonth + sDay;

            StreamWriter sw = new StreamWriter(HttpContext.Current.Server.MapPath(BCDataCenter.Globals.LoginLog() + "/LoginLog") + sErrorTime, true);
            sw.WriteLine(sLogFormat + "\t 1.User: " + User + "\n\t" + "2.IP Address: " + IP);
            sw.Flush();
            sw.Close();
        }
    }
}
